#include <stdio.h>
#include <math.h>

int gcd(int a1,int a2)
{
	if(a1 == a2)return a1;
	if(a1%a2 == 0)return a2;
	else return gcd(a2,a1%a2);
}
int main()
{
	int a,b,temp;
	scanf("%d %d",&a,&b);
	if(a<b){
		temp = a;
		a = b;
		b = temp;
	}
	int anwser = gcd(a,b);
	printf("%d\n",anwser);
	return 0;
}